import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { STColumn } from '@delon/abc';
import { GridComponent, SupDic, HttpService } from 'lbf';

@Component({
  selector: 'app-test01-test0105',
  templateUrl: './test0105.component.html',
})
export class Test01Test0105Component implements OnInit {
  constructor(
    private http: _HttpClient,
    private supdic: SupDic,
    private lbservice: HttpService,
  ) {}
  record: any;
  dicMap = new Map<any, any>();

  params = {
    jgname: 'FR_zbjglist1',
    jgform: { tname: null },
    sjname: 'zbgl_zbllsjhq',
    sjform: { DAA027: null },
    logname: 'FR_qzblog',
    form: { DAA020: null },
  };

  /*******************指标数据*********************** */
  sjColumn: STColumn[] = [{ titsjColumnle: '表中无字段', index: 'TKA006' }];

  @ViewChild('sjst', { static: false }) sjst: GridComponent;
  sjscrool = { x: '300px' };
  jgDataset = [];

  /*********************指标结构************************ */
  jg_columns: STColumn[] = [
    { title: '字段编码', index: 'DAA006' },
    { title: '字段名称', index: 'DAA007' },
    { title: '数据标准', index: 'DAA008' },
    { title: '完成度', index: 'DAE003' },
    { title: '是否可空', index: 'DAA009' },
  ];

  /*********************指标日志************************ */
  log_columns: STColumn[] = [
    { title: '操作类型', index: 'DAA011' },
    { title: '操作详情', index: 'DAA002' },
    {
      title: '操作时间',
      index: 'AAE036',
      type: 'date',
      dateFormat: 'YYYY-MM-DD HH:mm',
    },
    { title: '操作员', index: 'AAE011' },
  ];

  /*******************指标数据初始化*********************** */
  initstcolumn() {
    const res = [];
    let sco = 0;
    this.jg_columns.forEach(ele => {
      const item = {};
      item['title'] = ele.DAA007;
      item['index'] = ele.DAA006;
      res.push(item);
      sco = sco + 100;
    });
    this.sjColumn = res;
    this.sjscrool.x = sco + 'px';
    this.sjst.st.scroll = this.sjscrool;
  }

  ngOnInit() {
    this.params = {
      jgname: 'FR_zbjglist1',
      jgform: { tname: this.record.DAA020 },
      sjname: 'zbgl_zbllsjhq',
      sjform: { DAA027: this.record.DAA027 },
      logname: 'FR_qzblog',
      form: { DAA020: this.record.DAA020 },
    };
    // 获取数据字典
    let enu: any = [];
    enu = this.supdic.getSFDic('zbzt');
    enu.forEach(ele => {
      this.dicMap.set('AAE100' + ele.value, ele.label);
    });
    enu = this.supdic.getSFDic('DAE001');
    enu.forEach(ele => {
      this.dicMap.set('DAE001' + ele.value, ele.label);
    });
    enu = this.supdic.getSFDic('DAA026');
    enu.forEach(ele => {
      this.dicMap.set('DAA026' + ele.value, ele.label);
    });
    enu = this.supdic.getSFDic('DAA024');
    enu.forEach(ele => {
      this.dicMap.set('DAA024' + ele.value, ele.label);
    });

    console.log(this.params);

    this.initstcolumn();
  }
}
